﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using WmWebSystem.Models;
using WmWebSystem.Service;
using WmWebSystem.DbHelper;

namespace WmWebSystem.Controllers
{
    public class ZoneController : Controller
    {
        //
        // GET: /Zone/

        [Authorize]
        public ActionResult Index()
        {
            string user=HttpContext.User.Identity.Name;
            var projects = ProjectHelper.FindAllProjectByStatus(1);
            var news=NewsHelper.FindAllNewsby(1);
            var attention = AttentionHelper.FindByUserName(user);
            var mypro = ProjectHelper.FindPrpjectByUserName(user);
            var comment = CommentHelper.FindAll();

            ViewData["newProjects"] = projects;
            ViewData["News"]=news;
            ViewData["Attentions"] = attention;
            ViewData["MyPros"] = mypro;
            ViewData["Comments"] = comment;
            return View();
        }

        [Authorize]
        public ActionResult MyProject() 
        {
            string user=HttpContext.User.Identity.Name;
            var projects = ProjectHelper.FindPrpjectByUserName(user);
            var attentions = AttentionHelper.FindAll();
            
            ViewData["myProjects"] = projects;
            ViewData["Attentions"] = attentions;
            return View();
        }

        //关注的项目
        [Authorize]
        public ActionResult MyAttention()
        {
            string user = HttpContext.User.Identity.Name;
            var attentions = AttentionHelper.FindByUserName(user);
            ViewData["myAttentions"] = attentions;
            return View();
        }

        //喜爱的音乐
        [Authorize]
        public ActionResult MyFavourite()
        {
            string user = HttpContext.User.Identity.Name;
            var favourites = FavouriteHelper.FindAllFavouriteHelper(user);
            ViewData["myFavourite"] = favourites;
            return View();
        }

        //入股的项目列表
        [Authorize]
        public ActionResult MyBeteiligung()
        {
            string user = HttpContext.User.Identity.Name;
            var finances = FinanceHelper.FindFinancesRecordBy(user);
            ViewData["myFinances"] = finances;
            return View();
        }

        [Authorize]
        public ActionResult AccountInf() 
        {
            string user = HttpContext.User.Identity.Name;
            var customer = UserAccountHelper.FindAccountByName(user);
            ViewData["myCustomer"] = customer;
            return View();
        }


    }
}
